﻿using System;
using System.Collections.Generic;
using Ur;

namespace Pixels.Logic.GameplayEvents
{
    class FoundSomethingWhileScoutingEvent : GameplayEvent
    {
        internal override void execute() {
            reward.applyEffects();
        }

        Tile tile;
        ScoutingReward reward;


        public FoundSomethingWhileScoutingEvent(Tile tile, ScoutingReward reward) {
            this.tile = tile;
            this.reward = reward;
        }

        internal override string getLongDescription() {
            return "While scouting, your soldiers have found " + reward.getDescription();
        }
    }
}

namespace Pixels.Logic
{
    public abstract class ScoutingReward
    {

        static public ScoutingReward createRandomReward()
        {
            // dice roll
            // return one of the rewards
            var rand = Ur.Random.QuickRnd.range(1, 9);

            

            switch (rand)
            {
                case 1: 
                case 2: 
                    return new FrozenPodReward();
                case 3: 
                case 4:
                case 5:
                    return new CogReward();
                case 6:
                    return new TransponderReward();
                case 7:
                case 8:
                case 9:
                    return new BadReward();
                default:
                    return null;
            }

        }

        public virtual string getDescription() {
            return "SOME CASH";
        }

        public virtual void applyEffects()
        {
            World.Colony.accumulatedResources.changeResource(Resource.Cogs, 2);
        }
    }

    public class FrozenPodReward : ScoutingReward
    {

        public override string getDescription()
        {
            return "some people frozen in escape pods";
        }

        public override void applyEffects()
        {
            for (int i = 0; i < Ur.Random.QuickRnd.range(1,3); i++) World.Colony.spawnColonist(Colonist.Occupation.colonist);
            
            
        }
    }


    public class TransponderReward : ScoutingReward
    {

        public override string getDescription()
        {
            return "the transponder needed for long distance communication";
        }

        public override void applyEffects()
        {
            //SET FLAG


        }
    }

    public class CogReward : ScoutingReward
    {

        public override string getDescription()
        {
            return "valuable resources";
        }

        public override void applyEffects()
        {
            World.Colony.accumulatedResources.changeResource(Resource.Cogs, Ur.Random.QuickRnd.range(1,3));


        }

    }

    public class BadReward : ScoutingReward
    {

        public override string getDescription()
        {
            return "an angry alien";
        }

        public override void applyEffects()
        {
            //World.Colony.removeColonist(Colonist.Occupation.soldier);


        }
    }



}
